package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:varchar(30)" json:"mobile,omitempty"`
	Password string `gorm:"type:char(32)" json:"password,omitempty"`
	Status   int    `gorm:"type:int(11)" json:"status,omitempty"`
}

func (u *User) GetByMobile() error {
	return DB.Where("mobile = ?", u.Mobile).Limit(1).Find(&u).Error
}
func (u *User) GetById() error {
	return DB.Where("id = ?", u.ID).Limit(1).Find(&u).Error
}
func (u *User) Create() error {
	return DB.Create(&u).Error
}
